<template>
  <view style="font-size: 14px;">
    <public-header :title="config.titleText||title"></public-header>
    <!-- eqwew -->
    <!-- <gBack :title="config.titleText"></gBack> -->
    <bUpdate :mainService="service"  class="retail-list-update" ref="bUpdate" :page="config.page" :editorType="type" :config="config"
      :condition="condition"></bUpdate>
  </view>
</template>

<script>
  import bUpdate from '@/components/g-batch-update/g-batch-update.vue'
  import gBack from '@/components/g-batch-update/g-page-back.vue'
  import lockscreen from '@/common/mixins/lockscreen.js'
  export default {
    mixins: [lockscreen],
    data() {
      return {
        title: "",
        service: "", // 页面service
        type: "", // 页面编辑模式
        config: {
          serviceName: "srvretail_warehousing_aio_select",
          listLayout: "batchList", // listAndDetail listAndFilter  list  batchList
          defaultData: "batch-select", // batch-select   service-loading
          detailPath: "simple", //  simple  基础的； 或者配置页面路由 路由格式待定
          page: {
            pageNo: 1,
            rownumber: 20
          },
          listHeaders: [''],
          childService: "srvretail_warehousing_detail_select",
          childKeyCol: "", // 子表数据的主键
          tabsType: "custom", //
          titleText: "返回",
          title: "",
          condition: [],
          popupColumns: ["inventory_num", "goods_stock", "profit_loss_num", "cost_price", "profit_loss_amount"],
          custTabs: [{
            "colName": "warehousing_no",
            "type": "input",
            "inputType": "String",
            "parent": "",
            "is_count": false,
            "show_expr": {},
            "label": "入库单号",
            "showLabel": true,
            "default": "",
            "colspan": 24,
            "showAllTag": false,
            "tags": [],
            "appendSearchButton": true
          }],
          tabs: {
            layout: 'inline', // 'inline'   block
          }
        },
        condition: []
      }
    },
    components: {
      bUpdate,
      gBack
    },

    methods: {

      buildMenChildUpdate(srv) {
        switch (srv) {
          case 'srvretail_warehousing_update':
          case 'srvretail_warehousing_add':
          case 'srvretail_warehousing_select':
            this.config.popupColumns = ["warehousing_num", "purchase_price", "purchase_amount"]
            break;
          case 'srvretail_warehousing_aio_select':
            this.config.popupColumns = ["warehousing_num", "purchase_price", "purchase_amount"]
            break;
          case 'srvretail_issue_update':
          case 'srvretail_issue_add':
          case 'srvretail_issue_select':
            this.config.popupColumns = ["issue_num", "shipment_price", "shipment_amount"]
            break;
          case 'srvretail_issue_select':
            this.config.popupColumns = ["issue_num", "shipment_price", "subtotal_amount", 'shipment_amount']
            break;
          case 'srvretail_inventory_update':
          case 'srvretail_inventory_add':
            this.config.popupColumns = ["inventory_num", "goods_stock", 'profit_loss_amount','profit_loss_amount']
            break;
          case 'srvretail_inventory_select':
            this.config.popupColumns = ["inventory_num", "goods_stock", "profit_loss_num", "cost_price",
              "inventory_type", "profit_loss_amount"
            ]
            break;
          case 'srvretail_loss_reporting_add':
          case 'srvretail_loss_reporting_update':
          case 'srvretail_loss_reporting_select':
            this.config.popupColumns = ["loss_num", "cost_price", "loss_reason", "cost_amount"]
            break;
          default:
            break;
        }
      }
    },
    onLoad(option) {
      if (option.title || option.titleText) {
        this.title = option.title || option.titleText
      }
      this.service = option.serviceName
      this.type = option.type
      if ((option.type == 'detail' || option.type == 'update') && option.hasOwnProperty('id')) {
        this.config.serviceName = option.serviceName
        this.config.defaultData = 'service-loading'
        this.condition.push({
          colName: "id",
          ruleType: "eq",
          value: option.id
        })
        this.config.title = option.title
        this.config.titleText = option.titleText
        this.config.childKeyCol = option.childKeyCol
        this.config.submit_time = option.submit_time
        this.config.create_time = option.create_time
        this.config.operator_name = option.operator_name
        this.config.state = option.state
        this.config.deleteService = option.deleteService
        this.buildMenChildUpdate(option.serviceName)
      } else if (option.type == 'add') {
        this.config.serviceName = option.serviceName
        this.config.titleText = option.titleText
        this.buildMenChildUpdate(option.serviceName)

      }

    }
  }
</script>

<style lang="scss" scoped>
  .retail-list-update {
    height: calc(100vh - 6rem);

    ::v-deep .retail-list {
      height: calc(100vh - 6rem);
    }
  }
</style>
